package com.vecspace.dayu.code.ui.dao;

import java.util.List;
import org.springframework.stereotype.Repository;

import com.vecspace.database.dao.BaseDao;
import com.vecspace.dayu.code.ui.pojo.DataTree;

/** DAYU-页面树结构配置,操作数据库的dao类
 * @author: wanghua
 * @reviewer:
 * @template：wanghua
 */
@Repository("dayu_dataTreeDao")
public class DataTreeDao extends BaseDao {
	/** 根据ID查询 DAYU-页面树结构配置
	 * @param id   主键值
	 * @return DataTree
	 * @throws Exception
	 * @author wanghua
	 */
	public DataTree getDataTree(Long id) throws Exception {
		DataTree dataTree = null;
		if (id != null && id != 0) {

			dataTree = this.queryObject(DataTree.class, id);
			this.evict(dataTree);
		}
		return dataTree;
	}
	
	public List<DataTree> getDataTrees(Long funcId) throws Exception {
		List<DataTree> dataTrees = this.queryObjectList("from DataTree where funcId=?0 order by ordnum", new Object[] {funcId});
		return dataTrees;
	}
	
	public DataTree getDataTreeByTableIdAndTerminalType(Long tableId, String terminalType) throws Exception {
		DataTree dataTree = this.queryObject("from DataTree where tableId=?0 and platformType=?1", new Object[] {tableId, terminalType});
		return dataTree;
	}

	/** 插入或修改 DAYU-页面树结构配置 
	 * @param item	要保存的对象
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void saveDataTree(DataTree item) throws Exception {
		this.saveOrUpdateObject(item);
		this.evict(item);
	}

	/** 根据ID删除 DAYU-页面树结构配置 
	 * @param id	主键值
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void deleteDataTree(Long id) throws Exception {
		if (id != null && id != 0) {
			this.deleteObject(DataTree.class, id);
		}
	}
}
